<!-- 图片 -->
<script lang="ts" setup>
import type { PropType } from 'vue'
import { computed, ref } from 'vue'

const props = defineProps({
  src: {
    type: String,
    default: ''
  },
  fit: {
    type: String,
    default: ''
  },
  previewSrcList: {
    type: Array as PropType<string[]>,
    default() {
      return [] as string[]
    }
  },
  previewTeleported: {
    type: Boolean,
    default: true
  }
})

// 图片前缀
const imgFixUrl = ref(import.meta.env.VITE_FILE_URL)
// 完整路径
const filterUrl = computed(() => {
  return imgFixUrl.value + props.src
})
</script>

<template>
  <el-image
    class="my-image"
    :src="filterUrl"
    :fit="fit"
    :previewSrcList="previewSrcList"
    :previewTeleported="previewTeleported"
  />
</template>

<style lang="scss" scoped>
.my-image {
  width: 100%;
  height: 100%;
}
</style>
